//
//  SADate.m
//  01_kakin
//
//  Created by jon due on 12/03/19.
//  Copyright (c) 2012年 __MyCompanyName__. All rights reserved.
//

#import "SADate.h"

@implementation SADate


-(void) dealloc{
    [ super dealloc ];
}

// 曜日を取得する
+(int)getWeek{
    
    NSDate *date = [NSDate date];
    NSCalendar *calendar = [NSCalendar currentCalendar];
    NSDateComponents *comps;
    
    // 週や曜日などをとりだす
    comps = [calendar components:(NSWeekCalendarUnit | NSWeekdayCalendarUnit | NSWeekdayOrdinalCalendarUnit) fromDate:date];
    NSInteger weekday = [comps weekday]; // 曜日
    
    // 7が日曜日
    return weekday - 1;
}

// 日付をフォーマット通に表示する
+(NSArray*)getDate{
    
    // 日付を計算
    NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
    
    [formatter setDateFormat:@"yyyy/MM/dd"];
    NSString *date = [formatter stringFromDate:[ NSDate date ]];
    [formatter setDateFormat:@"HH:MM"];
    NSString *time = [formatter stringFromDate:[ NSDate date ]];
    
    [ formatter release ];

    
    NSArray *ary =  [[[ NSArray alloc ]initWithObjects:date,time, nil] autorelease];
    
    return ary;
}

@end
